package 牛客题霸;

public class 买卖股票的最好时机1 {

    public int maxProfit (int[] prices) {
        if(prices == null || prices.length <= 0) {
            return 0;
        }
        int min = prices[0];
        int max = 0;
        for (int i = 0; i < prices.length; i++) {
            min = Math.min(min,prices[i]);
            max = Math.max(max,prices[i] - min);
        }
        return max;
    }

    public static void main(String[] args) {

    }
}
